import com.alibaba.fastjson.JSON

/**
  * Created by TQ on 2017/10/27.
  */
object TestJson {


  def main(args: Array[String]): Unit = {

    val jj = "{\"imei\":\"zhd-54046\",\"sim\":null,\"acc\":0,\"powerAlarm\":0,\"gpsSignal\":0,\"gsmSignal\":17,\"electricity\":4180,\"voltage\":4180,\"serialNumber\":null,\"workStatus\":null,\"gpsTime\":1494828000.000000000,\"lng\":106601300,\"lat\":29713716,\"course\":0,\"altitude\":null,\"speed\":0,\"gpsStatus\":0, \"latStatus\":null,\"lngStatus\":null,\"targetingStatus\":0,\"speedAlarm\":0,\"mcc\":null,\"mnc\":null,\"cellId\":20222,\"lac\":13145,\"receiveTime\":1494834543.646000000,\"oilStatus\":0,\"vibrationAlarm\":0,\"ip\":null,\"port\":null,\"areaAlarm\":0,\"workStyle\":1}"
    val json = JSON.parseObject(jj)

    println(json.getString("imei"))
    println(json.getString("lng"))
    println(json.getString("lat"))

    import javax.script.ScriptEngineManager
    val sem = new ScriptEngineManager
    val se = sem.getEngineByName("js")
    val jsonstr = "({name: 1, obj: 3,[dd]})"
    try
      System.out.println(se.eval("( )"))
    catch {
      case e: Exception =>
        System.out.println("json格式有误")
    }
  }
}
